## ## PSPChess ## Copyright (C) 2009,2010 Germano Fabio ## gefasio@gmail.com ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## class Animation(object): def __init__(self, src, listImages, timer, x, y): ''' (Screen/Image Instance) src -> Where to blit the images. (list) listImages -> Images list to show. (int) timer -> Each timer shows an images in listImages. (int) x -> X cartesian position. (int) y -> Y cartesian position. ''' self.src = src self.listImages = listImages self.timer = timer self.currTimer = 0 self.currImage = 0 self.pos = [x, y] def show(self): ''' Shows animation. =) This method must be called each time in a cicle. ''' self.src.blit(self.listImages[self.currImage], 0, 0, self.listImages[self.currImage].width,\ self.listImages[self.currImage].height, self.pos[0], self.pos[1], True) self.currTimer += 1 if self.currTimer > self.timer: self.currTimer = 0 if self.currImage < len(self.listImages) - 1: self.currImage += 1 else: self.currImage = 0 def reset(self): ''' Resets animation. ''' self.currImage = 0 self.currTimer = 0